package com.kgc.ssm.controller;

import com.kgc.ssm.entity.dto.QuoteDe;
import com.kgc.ssm.entity.dto.Result;
import com.kgc.ssm.service.QuoteDeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("/quotede")
public class QuoteDeController {
    @Autowired
    private QuoteDeService quoteDeService;

    @GetMapping("/details")
    public List<QuoteDe> selectByTitles(@RequestParam String queTitles) {
        String[] titles = queTitles.split(" ");
        System.out.println("queTitles:" + queTitles);
        System.out.println("titles: " + Arrays.toString(titles));
        return quoteDeService.selectByTitles(titles);
    }

    @GetMapping("/quotaDetails")
    public List<QuoteDe> selectByMaterialCode(@RequestParam String materialCodes) {
        String[] titles = materialCodes.split(" ");
        System.out.println("materialCodes:" + materialCodes);
        System.out.println("titles: " + Arrays.toString(titles));
        return quoteDeService.selectByMaterialCode(titles);
    }

    @PostMapping("/maintain")
    public Result<QuoteDe> updateQuoteDe(@RequestBody List<QuoteDe> formDatas) {
        // 调用 Service 层方法处理业务逻辑
        return quoteDeService.updateQuoteDe(formDatas);
    }
}
